package com.tanhua.manage.controller;

import com.tanhua.manage.service.RetentionService;
import com.tanhua.manage.util.NoAuthorization;
import com.tanhua.manage.vo.RetentionVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.text.ParseException;
import java.util.Date;
import java.util.List;

@RestController
@Slf4j
public class RetentionController {


    @Autowired
    private RetentionService retentionService;


    /**
     * 保存信息并查询
     */
    @GetMapping("/retention/date")
    @NoAuthorization
    public List<RetentionVo> saveAndQueryAllRetention() {

        try {
            return this.retentionService.saveAndQueryAllRetention();
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return null;
    }


    /**
     * 筛选留存率
     */
    @GetMapping("/retention/part")
    @NoAuthorization
    public List<RetentionVo> getPartRetention(@RequestParam(name = "sd") String sd,
                                              @RequestParam("ed") String ed,
                                              @RequestParam("sex") Integer sex) {

        return this.retentionService.getPartRetention(sd, ed,sex);
    }

    /**
     * 查询全部留存率
     */

    /*@GetMapping("/retention/all")
    public List<RetentionVo> getAllRetention() {
        return this.retentionService.getAllRetention();
    }*/

}
